package com.project.estate.car.controller;

import com.project.estate.car.service.CarService;
import com.project.estate.commons.bean.Car;
import com.project.estate.commons.config.JsonResult;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/car")
public class CartController {

    @Resource
    private CarService carService;


    @PostMapping("/add_car")
    public JsonResult addCart(Car car) {
        return carService.addCar(car);
    }

    //删除
    @DeleteMapping("/delete_car/{prid}")
    public JsonResult deleteCar(@PathVariable("prid") String prid) {
        return carService.deleteCar(prid);
    }

    //查询
    @GetMapping("/find_car/{prid}")
    public JsonResult findCar(@PathVariable("prid") String prid) {
        return carService.findCar(prid);
    }

    //修改
    @PostMapping("/update_car/{prid}")
    public JsonResult updateCar(Car car,  @PathVariable("prid") String prid) {
        return carService.updateCar(prid,car);
    }

    //查询
    @GetMapping("/find_all_car")
    public JsonResult findAllCar() {
       return carService.findAllCars();
    }
}
